package com.shortvedio.base.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shortvedio.base.model.dto.VedioContentDto;
import com.shortvedio.base.model.po.VideosContent;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface VideosContentMapper extends BaseMapper<VideosContent> {
    @Select("SELECT * FROM videos_content WHERE user_id =#{userId} AND STATUS = #{status}")
    public List<VedioContentDto> selectMyVideos(@Param("userId") Long userId, @Param("status") Integer status);//获取自己的视频--根据不同的状态

    @Select("SELECT videos_content.* FROM videos_content LEFT JOIN videos_about ON videos_content.`id` = videos_about.`videos_id` ORDER BY like_count*1.5+favorites_count*1.5+look_count+comments_count*2 DESC LIMIT #{start},#{size}")
    public List<VedioContentDto> selectHotVideos(@Param("start") Integer start, @Param("size") Integer size);//获取热门视频

    @Select("select * from videos_content where type=#{type} order by upload_time ASC limit #{start},#{size}")
    public List<VedioContentDto> selectTypeVideos(@Param("type")Integer type,@Param("start") Integer start, @Param("size") Integer size);//获取指定类型的视频

    @Select("SELECT * FROM videos_content WHERE id IN (SELECT videos_id FROM videos_about WHERE like_count*1.5+favorites_count*1.5+look_count+comments_count*2 >1000) AND status = 2 ORDER BY RAND() LIMIT 1")
    public List<VedioContentDto> getHotVideos();//获取推荐的热门视频
}
